import React from 'react';
import {StyleSheet, View, WebView} from 'react-native';

import config from '../../../common/config';

import Header from '../../../components/header';

export default class extends React.Component {
    state = {
        title: '',
        canGoBack: false
    };
    historyChange = (state) => {
        const {title, canGoBack} = state;
        this.setState({
            title,
            canGoBack
        });
    };

    backFn = () => {
        this.refs._webView.goBack();
    };

    render() {
        return (
            <View style={styles.container}>
                <Header title="新手攻略"/>
                <WebView ref="_webView"
                         source={{uri: `${config.baseUrl}webview/novice`}}
                         javaScriptEnabled={true}
                         domStorageEnabled={true}
                         startInLoadingState={true}
                         onNavigationStateChange={this.historyChange}
                         scalesPageToFit={false}/>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        backgroundColor: '#f0f0f0',
        flex: 1
    }
});
